package com.xcc.myredis.runner;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
public class MyApplicationRunner implements ApplicationRunner {

    /**
     *  如果是:java -jar spring-boot-demo.jar data1 data2 --foo=1232
     *      args.getSourceArgs()为解析出来的参数为{data1,data2,--foo=1232}
     *      args.getOptionNames()为[foo]
     *      args.getOptionValues("foo")为1232
     * @param args 封装之后的数据
     */
    @Order(1) //Order的值越小就越先执行
    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println("===MyApplicationRunner==="+ Arrays.asList(args.getSourceArgs()));
        System.out.println("===getOptionNames========"+args.getOptionNames());
        System.out.println("===getOptionValues======="+args.getOptionValues("foo"));
        System.out.println("==getOptionValues========"+args.getOptionValues("developer.name"));
    }
}
